package com.citcc.framework.sms;



import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;

import com.citcc.common.utils.StringUtils;



public abstract class MessageUtil {

    private static final String SIGN_NAME = "绿能充";
    private static final String ACCESS_KEY_SECRET = "FL0wVNB6Kdf2Xfsa8BcWPDpPbzYBrL";
    private static final String ACCESS_KEY_ID = "LTAIRQqF7uTiVQfv";


    static {
        System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
        System.setProperty("sun.net.client.defaultReadTimeout", "10000");
    }



    public static JsonResult smsCode(String phone, String code) {
        SMSSender sender = new SMSSender(ACCESS_KEY_ID, ACCESS_KEY_SECRET);
        SMSCarrier carrier = new SMSCarrier();
        carrier.setPhoneNumbers(phone);
        carrier.setTemplateParam("{\"code\":\"" + code + "\"}");
        carrier.setTemplateCode("SMS_95600022");
        carrier.setSignName(SIGN_NAME);
        return sender.sendSMS(carrier);
    }

    public static JsonResult smsCode(String phone, String code, String template) {
        SMSSender sender = new SMSSender(ACCESS_KEY_ID, ACCESS_KEY_SECRET);
        SMSCarrier carrier = new SMSCarrier();
        carrier.setPhoneNumbers(phone);
        carrier.setTemplateParam("{\"code\":\"" + code + "\"}");
        carrier.setTemplateCode(template);
        carrier.setSignName(SIGN_NAME);
        return sender.sendSMS(carrier);
    }

    public static JsonResult smsTemplate(String phone) {
        SMSSender sender = new SMSSender(ACCESS_KEY_ID, ACCESS_KEY_SECRET);
        SMSCarrier carrier = new SMSCarrier();
        carrier.setPhoneNumbers(phone);
        carrier.setTemplateCode("SMS_137417476");
        carrier.setSignName(SIGN_NAME);
        return sender.sendSMS(carrier);
    }

    public static JsonResult smsTemplate(String phone, String template, String param) {
        SMSSender sender = new SMSSender(ACCESS_KEY_ID, ACCESS_KEY_SECRET);
        SMSCarrier carrier = new SMSCarrier();
        carrier.setPhoneNumbers(phone);
        carrier.setTemplateCode(template);
        carrier.setSignName(SIGN_NAME);
        if (StringUtils.isNotEmpty(param)) {
            carrier.setTemplateParam(param);
        }
        return sender.sendSMS(carrier);
    }
    
    public static void main(String[] args) throws Exception{
    	
    	
	}
    
}
